package cn.com.shopec.erp.purchase.commo;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Component;

import cn.com.shopec.erp.common.page.PageFinder;
import cn.com.shopec.erp.common.utils.DateUtil;
import cn.com.shopec.erp.common.utils.LogicUtil;
import cn.com.shopec.erp.purchase.entity.PurchaseOrder;
import cn.com.shopec.erp.purchase.entity.PurchaseRequisitionProduct;
import cn.com.shopec.erp.purchase.vo.PurchaseOrderVo;
import cn.com.shopec.erp.purchase.vo.PurchaseRequisitionProductVo;
import cn.com.shopec.erp.system.common.UserUtils;

@Component
public class PurchaseRequisitionProductVoConvertor {
	
	 public List<PurchaseRequisitionProductVo> convert2DefectiveVos(List<PurchaseRequisitionProduct> purchaseList) {
	        List<PurchaseRequisitionProductVo> purchaseVos = null;

	        if (LogicUtil.isNotNullAndEmpty(purchaseList)) {
	        	purchaseVos = new ArrayList<PurchaseRequisitionProductVo>();

	            for (PurchaseRequisitionProduct purchaseOrder : purchaseList) {
	            	PurchaseRequisitionProductVo purchaseVo = this.convert2DefectiveVo(purchaseOrder);
	            	purchaseVos.add(purchaseVo);
	            }
	        }

	        return purchaseVos;
	    }

	
	 public PageFinder<PurchaseRequisitionProductVo> convert2PagedDefectiveVos(PageFinder<PurchaseRequisitionProduct> pagedBrands) {
	        PageFinder<PurchaseRequisitionProductVo> pagedBrandVos = null;

	        if (LogicUtil.isNotNull(pagedBrands.getData())) {
	            List<PurchaseRequisitionProductVo> defectiveVos = this.convert2DefectiveVos(pagedBrands.getData());

	            pagedBrandVos = new PageFinder<PurchaseRequisitionProductVo>(pagedBrands.getPageNo(), pagedBrands.getPageSize(),
	                    pagedBrands.getRowCount(), defectiveVos);
	        }

	        return pagedBrandVos;
	    }
	 
	 public PurchaseRequisitionProductVo convert2DefectiveVo(PurchaseRequisitionProduct purchaseRequisitionProduct) {
		 PurchaseRequisitionProductVo purchaseRequisitionProductVo = null;
	        if (LogicUtil.isNotNull(purchaseRequisitionProduct)) {
	        	purchaseRequisitionProductVo = new PurchaseRequisitionProductVo();
	        	purchaseRequisitionProductVo.setPoNo(purchaseRequisitionProduct.getPoNo());
	        	purchaseRequisitionProductVo.setId(purchaseRequisitionProduct.getId());
	        	purchaseRequisitionProductVo.setProductNo(purchaseRequisitionProduct.getProductNo());
	        	purchaseRequisitionProductVo.setPpName(purchaseRequisitionProduct.getPpName());
	        	purchaseRequisitionProductVo.setProductNo(purchaseRequisitionProduct.getProductNo());
	        	purchaseRequisitionProductVo.setPpSpecification(purchaseRequisitionProduct.getPpSpecification());
	        	purchaseRequisitionProductVo.setPpUnit(purchaseRequisitionProduct.getPpUnit());
	        	purchaseRequisitionProductVo.setPpNumber(purchaseRequisitionProduct.getPpNumber());
	        	purchaseRequisitionProductVo.setPpSupplierNo(purchaseRequisitionProduct.getPpSupplierNo());
	        	purchaseRequisitionProductVo.setPpSupplierName(purchaseRequisitionProduct.getPpSupplierName());
	        	purchaseRequisitionProductVo.setPpWarehouseNo(purchaseRequisitionProduct.getPpWarehouseNo());
	        	purchaseRequisitionProductVo.setPpWarehouseName(purchaseRequisitionProduct.getPpWarehouseName());
	        	purchaseRequisitionProductVo.setDeleteFlag(purchaseRequisitionProduct.getDeleteFlag());
	        	purchaseRequisitionProductVo.setTotalPrice(purchaseRequisitionProduct.getTotalPrice());
	        	purchaseRequisitionProductVo.setSalePrice(purchaseRequisitionProduct.getSalePrice());
	        	purchaseRequisitionProductVo.setCommodityNo(purchaseRequisitionProduct.getCommodityNo());
	        	purchaseRequisitionProductVo.setProdBarCode(purchaseRequisitionProduct.getProdBarCode());
	        	purchaseRequisitionProductVo.setPpUnitPrice(purchaseRequisitionProduct.getPpUnitPrice());
	        	purchaseRequisitionProductVo.setReturnNumber(purchaseRequisitionProduct.getReturnNumber());
	        	purchaseRequisitionProductVo.setRetunStatus(purchaseRequisitionProduct.getRetunStatus());
	        	purchaseRequisitionProductVo.setBuyNum(purchaseRequisitionProduct.getBuyNum());
	        	purchaseRequisitionProductVo.setShelfLife(purchaseRequisitionProduct.getShelfLife());
	        	purchaseRequisitionProductVo.setManufactureTime(purchaseRequisitionProduct.getManufactureTime());
	        }
	        return purchaseRequisitionProductVo;
	    }
	 
	 /**
	  * 修改采购信息
	  * @param purchaseOrderVo
	  * @param purchaseOrder
	  * @return
	  */
	 public PurchaseRequisitionProduct convert2Defective(PurchaseRequisitionProductVo purchaseOrderVo) {

	        if (LogicUtil.isNotNull(purchaseOrderVo)) {
	        	PurchaseRequisitionProduct purchaseOrder=new PurchaseRequisitionProduct();
	        	purchaseOrder.setId(purchaseOrderVo.getId());
	        	purchaseOrder.setPpNumber(purchaseOrderVo.getPpNumber());
	        	purchaseOrder.setSalePrice(purchaseOrderVo.getSalePrice());
	        	purchaseOrder.setTotalPrice(purchaseOrderVo.getTotalPrice());
	            return purchaseOrder;
	        } else {
	            return null;
	        }
	    }
	 
	 
}
